home *** CD-ROM | disk | FTP | other *** search
- /*
- * Module Starter Main.c
- *
- * This is a shell that you should use when beginning a new module.
- *
- *
- * This program source code and it's compiled version is
- * Copyright (c) 1991 N. Hawthorn.
- * This program source code and it's compiled version IS NOT IN THE
- * PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
- * regarding use of this program source code and it's compiled version.
- *
- * This module's name is "shell", it's type is "MOD1", it's ID is 999
- *
- * SET YOUR PROJECT UP LIKE THIS!!!!
- *
- * Under "Edit Menu, Options", MACHEADERS OFF!, MACSBUG OFF!,
- * REQUIRE PROTOTYPES OFF!
- *
- * Under "Project Menu, Set Project Type", Attrs = 20 !!
- *
- * THIS PROJECT IS SET UP CORRECTLY, MAKE SURE YOU SET ANY OTHERS YOU DO
- * THIS WAY !! IF YOU DON'T WEIRD THINGS WILL HAPPEN AND YOU WILL SPEND
- * THE REST OF YOUR LIFE LOOKING THROUGH YOUR CODE FOR SOMETHING THAT
- * AIN'T THERE.
- *
- * If you don't read through "Writing MUBBS Modules" then not only are you
- * wasting MY time, you are wasting your OWN by being LAZY !
- *
- * Try NOT to include MacTraps, you really don't need it.
- *
- *
- * This is where it all starts...
- *
- */
-
- #define INMAIN
-
- #include <SetUpA4.h>
- #include "MUBBS Module.h"
-
- /* Prototypes for this file, we leave "Require Prototypes" off while developing
- * but build prototypes when we are ALMOST done testing the module. This may
- * catch some bugs that we missed! I use "Protoclip" a FKEY that is freeware
- * and available on the Support BBS.
- */
-
- pascal void main(int mode1, struct GS *G1, Ptr P1);
- int doshell(void);
-
- /* my globals for this file (put your globals below)
- GLOBALS ARE TRICKY ! (this is a multi line BBS)
- */
-
-
-
- /* the following code is the "main" code. For most "normal" modules, just
- change the programmers name to your own and put your code in the
- "doshell" function.
- */
-
- pascal void main (mode1,G1,P1) /* called from the main routines, and what mode to be in */
- int mode1;
- struct GS *G1; /* we point to the "global" struct in the Main Module here */
- Ptr P1; /* we ignore this pointer, we do not use it at all */
- {
- Handle temph;
- float version = 1.0; /* what version of MUBBS you are compatable with IE: 1.0 and above
- MAKE SURE YOU ARE COMPATABLE BEFORE SETTING THIS LESS THAN THE
- VERSION OF MUBBS YOU ARE DEVELOPING THIS FOR ! */
-
- RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
- asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
-
- G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
- mode[u]=mode1; /* set up our mode so that you can read it anywhere */
-
- switch (mode[u]) { /* any un-handled modes return error from this module */
- /* modes are
- 0= Return the programmers name and the module's type & version only.
- 1= Bye bye call, if you returned 99 for a init call, you
- get called when the program quits with mode=1.
- You should do a "unlock" to release your module's memory space
- and unlock any memory you allocated.
- 2= Normal call, no pointer passed.
- 3= Call with a pointer to a data struct (for passing data to a module).
- 98= do a version check against MUBBS version.
- */
-
- case 2:
- doshell();
- G->moduleresult=0;
- break;
- case 98:
- versionck(version); /* just return after this call, don't modify anything */
- break;
- case 0:
- strcpy (G->programmer,"N Hawthorn"); /* show the programmer's name up to 20 chars*/
- strcpy (G->modtype,"shell V1.0"); /* module type & version up to 30 chars
- the TYPE isn't always the name! */
- G->moduleresult=0; /* if this was also a init call we need close call put 99 here */
- break;
- default:
- G->moduleresult=1; /* return bad code */
- };
-
- HUnlock(temph); /* unlocks this module, do this ! */
- RestoreA4(); /* call this when you are all done */
- }
-
-
-
- doshell() /* this is where you put all your ideas and dreams! */
- {
-
- if (!G->online[u]) return; /* do this check so we can log out if they hang up */
-
- loguser(G->modulename[u]); /* this tells where you are for remote sysop,
- or writes to a log file */
-
- /* you print the following so that the sysop can monitor use on the mac screen
- YOU DON'T HAVE TO PRINT THIS, you can print what you wish */
-
- print("C> Line %d %s, at: %s\n",(u+1),G->username[u],G->modulename[u]);
- send("Inside the SHELL! Line %d %s, at: %s]",(u+1),G->username[u],G->modulename[u]);
-
-
- /* start your code here..... */
-
-
- }
-